home *** CD-ROM | disk | FTP | other *** search
/ Aminet 34 / Aminet 34 (2000)(Schatztruhe)[!][Dec 1999].iso / Aminet / util / mouse / FreeMouse.lha / FreeMouse / CxCustom.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-02  |  2.0 KB  |  70 lines

  1.  
  2. #include <exec/types.h>
  3. #include <devices/inputevent.h>
  4. #include <libraries/commodities.h>
  5.  
  6. #include <clib/exec_protos.h>
  7. #include <clib/commodities_protos.h>
  8. #include <clib/alib_protos.h>
  9.  
  10. #include "ClickFront.h"
  11. #include "Cx.h"
  12.  
  13. #include "CxCustom.h"
  14.  
  15. extern struct CxContext *Cx;
  16.  
  17. /****************************************************************************
  18.   This routine does the actual input event processing.
  19.   The mouse-speed variable in the CxContext struct is scaled by the GUI
  20.   routines so that 100 has no effect (100% in the GUI), 50 is half speed, etc.
  21.   The x and y movements are scaled by multiplying them by Cx->MouseSpeed
  22.   and dividing by 100.  The significant thing about this routine is that
  23.   the remainder is kept, and at each stage, the remainder from the previous
  24.   movement is added.  This is what avoids the jerkiness often caused by
  25.   mouse accelerators.
  26. ****************************************************************************/
  27.  
  28. void CxCustomRoutine(CxMsg *msg,CxObj *obj)
  29. {
  30.   static int xrem=0,yrem=0,lmb;
  31.   int x,y,msx,msy;
  32.   struct InputEvent *e=CxMsgData(msg);
  33.  
  34.   x=e->ie_X; y=e->ie_Y;
  35.   msx=Cx->MouseSpeed;
  36.   msy=Cx->MouseSpeed;
  37.   if(Cx->MMBShift)
  38.   {
  39.     if(e->ie_Qualifier & IEQUALIFIER_MIDBUTTON)
  40.     {
  41.       e->ie_Qualifier&=~IEQUALIFIER_MIDBUTTON;
  42.       e->ie_Qualifier|=IEQUALIFIER_LEFTBUTTON|IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT;
  43.     }
  44.   }
  45.   switch(e->ie_Class)
  46.   {
  47.     case IECLASS_RAWMOUSE:
  48.       if(Cx->MMBShift)
  49.       {
  50.         if(e->ie_Code==(IECODE_MBUTTON))
  51.           e->ie_Code=IECODE_LBUTTON;
  52.         if(e->ie_Code==(IECODE_MBUTTON|IECODE_UP_PREFIX))
  53.           e->ie_Code=IECODE_LBUTTON|IECODE_UP_PREFIX;
  54.       }
  55.       if(e->ie_Code==(IECODE_LBUTTON))
  56.         if(Cx->ClickToFront)
  57.           HandleClickToFront(e);
  58.       if(msx>150)
  59.         if(x<3 && x>-3)
  60.           msx=100;
  61.       if(msy>150)
  62.         if(y<3 && y>-3)
  63.           msy=100;
  64.         x=e->ie_X*msx+xrem; xrem=x; x/=100; xrem-=x*100; e->ie_X=x;
  65.         y=e->ie_Y*msy+yrem; yrem=y; y/=100; yrem-=y*100; e->ie_Y=y;
  66.         break;
  67.     }
  68. }
  69.  
  70.